package com.llyb.tingshu.album.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.llyb.tingshu.model.album.TrackInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.llyb.tingshu.query.album.TrackInfoQuery;
import com.llyb.tingshu.vo.album.AlbumTrackListVo;
import com.llyb.tingshu.vo.album.TrackListVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface TrackInfoMapper extends BaseMapper<TrackInfo> {


    IPage<TrackListVo> selectUserTrackPage(Page<TrackListVo> page, @Param("vo") TrackInfoQuery trackInfoQuery);

    @Update("update track_info set order_num = order_num -1 where album_id = #{albumId} and order_num > #{orderNum};")
    int updateOrderByOrderNum(@Param("albumId") Long albumId,@Param("orderNum") Integer orderNum);

    IPage<AlbumTrackListVo> selectPageByAlbumId(IPage<AlbumTrackListVo> iPage,@Param("albumId") Long albumId);
}
